package com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.bo.ITXingzhengshouwenNeirongBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.vo.TXingzhengshouwenNeirong;
import com.tjsinfo.tjsoa.workflow.WorkFlowTemplate;

public class ShouWenListAction  extends Action{
	private ITXingzhengshouwenNeirongBO xingzhengshouwenNeirongBO;
	
	


	public ITXingzhengshouwenNeirongBO getXingzhengshouwenNeirongBO() {
		return xingzhengshouwenNeirongBO;
	}




	public void setXingzhengshouwenNeirongBO(
			ITXingzhengshouwenNeirongBO xingzhengshouwenNeirongBO) {
		this.xingzhengshouwenNeirongBO = xingzhengshouwenNeirongBO;
	}




	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
		List<TXingzhengshouwenNeirong> list;
		JSONArray array = new JSONArray();		
		list =  xingzhengshouwenNeirongBO.selectDownXingzhengshouwenNeirong(SessionUser.getUserId(request), "行政发文");
		for (TXingzhengshouwenNeirong xingzhengshouwenNeirong : list) {
			JSONObject shouwenJSON = new JSONObject();
			shouwenJSON.put("state", "否");
			shouwenJSON.put("laiwenzihao", xingzhengshouwenNeirong.getLaiwenzihao());
			shouwenJSON.put("id", xingzhengshouwenNeirong.getId());
			shouwenJSON.put("laiwenjihuan", xingzhengshouwenNeirong.getLaiwenjiguan());
			shouwenJSON.put("zongshouwenhao", xingzhengshouwenNeirong.getShouwenbianhao());
			shouwenJSON.put("zhaiyao", xingzhengshouwenNeirong.getZhaiyou());
			shouwenJSON.put("shouwenriqi", ToolKit.FormatDate(xingzhengshouwenNeirong.getLaiwenriqi()));
			shouwenJSON.put("operate", "<a href='"+basePath+"tjsinfo/tjsoa/xingzhengshouwen/zhuanhuandengjifrom.do?dataBaseId="+xingzhengshouwenNeirong.getDataBaseId()+
						"&id="+xingzhengshouwenNeirong.getId()+"&taskId="+xingzhengshouwenNeirong.getTaskId()+"'>登记</a>"+"&nbsp;&nbsp;&nbsp;<a href='"+basePath+"tjsinfo/tjsoa/xingzhengshouwen/wuliuchengzhuanhuandengjifrom.do?dataBaseId="+xingzhengshouwenNeirong.getDataBaseId()+
							"&id="+xingzhengshouwenNeirong.getId()+"&taskId="+xingzhengshouwenNeirong.getTaskId()+"'>无流程登记</a>");			
			array.put(shouwenJSON);
		
		}				
		response.getWriter().print(array);
		return null;
	}
	
}

